var MaxCardIdUrl = "/GetMaxCardIdServlet";
var addUrl = "/AddUserServlet";

$(function () {
    userManage.initCardId();
})

var userManage = {};

userManage.initCardId = function () {
    $.ajax({
        url: MaxCardIdUrl,
        type: 'get',
        dataType: 'json',
        success: function (result) {
            if (result.data != null) {
                console.log(result.data)
                var res = result.data;
                var id = res[0].cardId;
                $("#cardId").val(id);
            }
        }
    })
}

userManage.adduser = function () {
    $.ajax({
        url: addUrl,// 自己完成后台
        type: 'post',
        data: {
            "userName": $("#userName").val(),
            "phone": $("#phone").val(),
            "levelId": $("#levelName").val(),
            "status": $("#status").val(),
            "staffId": window.localStorage.getItem("staffId"),
            "credit": $("#credit").val(),
            "amount": $("#amount").val(),
            "idCard": $("#idCard").val(),
            "sex": $("#sex").val(),
            "address": $("#address").val(),
            "area": $("#address").val(),
            "momo": $("#momo").val()
        },
        dataType: 'json',
        success: function (result) {
            console.log(result.status);
            if (result.status > 0) {
                toastr['success']("操作成功");
            } else {
                toastr['error']("操作失败");
            }
        }

    })
}